﻿using FreeSql.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZhonTai.Admin.Core.Entities;
using ZhonTai.Industry.Domain.PLCDevice;
using ZhonTai.Industry.Domain.WorkStation;

namespace ZhonTai.Industry.Domain.StationPlc
{
    /// <summary>
    /// 工站关联PLC
    /// </summary>
    /// <remarks>工站关联PLC</remarks>
    [Table(Name = "cfg_station_plc")]
    public class StationPlcEntity : EntityBase
    {
        /// <summary>
        /// 工位ID
        /// </summary>
        /// <remarks></remarks>
        public long WorkStationId { get; set; }

        /// <summary>
        /// PLC设备ID
        /// </summary>
        /// <remarks></remarks>
        public long PLCDeviceId { get; set; }

        /// <summary>
        /// PLC地址
        /// </summary>
        /// <remarks></remarks>
        [Column(StringLength = 64)]
        public string IpAddress { get; set; }

        /// <summary>
        /// 端口号
        /// </summary>
        /// <remarks></remarks>
        [Column(StringLength = 64)]
        public int Port { get; set; }

        /// <summary>
        /// 机架ID
        /// </summary>
        /// <remarks></remarks>
        [Column(Precision = 64)]
        public int RackId { get; set; }

        /// <summary>
        /// 插槽ID
        /// </summary>
        /// <remarks></remarks>
        [Column(Precision = 64)]
        public int SlotId { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        /// <remarks>排序</remarks>
        public int Sort { get; set; }

        /// <summary>
        /// 连接状态
        /// </summary>
        /// <remarks></remarks>
        [Column(StringLength = 64)]
        public string ConnectionStatus { get; set; }

        /// <summary>
        /// 最后连接时间
        /// </summary>
        /// <remarks></remarks>

        public DateTime LastConnected { get; set; }

        /// <summary>
        /// 启用
        /// </summary>
        public bool Enabled { get; set; }

        /// <summary>
        /// 工站信息
        /// </summary>
        [Navigate(nameof(WorkStationId))]
        public WorkStationEntity WorkStation { get; set; }

        /// <summary>
        /// PLC设备信息
        /// </summary>
        [Navigate(nameof(PLCDeviceId))]
        public PLCDeviceEntity PLCDevice { get; set; }
    }
}